﻿
using DevExpress.XtraReports.Parameters;
using DevExpress.XtraReports.UI;

namespace WindowsForms.AOnline.Report.Report
{
    public partial class StockBacklogReport : XtraReport
    {
        public StockBacklogReport()
        {
            InitializeComponent();
            txtInventoryItemCode.DataBindings.Add("Text", DataSource, "InventoryItemCode");
            txtInventoryItemName.DataBindings.Add("Text", DataSource, "InventoryItemName");
            txtUnit.DataBindings.Add("Text", DataSource, "Unit");
            txtQuantityOpening.DataBindings.Add("Text", DataSource, "QuantityOpening", "{0:n0}");
            txtQuantityInwardStock.DataBindings.Add("Text", DataSource, "QuantityInwardStock", "{0:n0}");
            txtQuantityOutwardStock.DataBindings.Add("Text", DataSource, "QuantityOutwardStock", "{0:n0}");
            txtQuantityClosing.DataBindings.Add("Text", DataSource, "QuantityClosing", "{0:n0}");

            txtOrgPriceOpening.DataBindings.Add("Text", DataSource, "OrgPriceOpening", "{0:n0}");
            txtOrgPriceInwardStock.DataBindings.Add("Text", DataSource, "OrgPriceInwardStock", "{0:n0}");
            txtOrgPriceOutwardStock.DataBindings.Add("Text", DataSource, "OrgPriceOutwardStock", "{0:n0}");
            txtOrgPriceClosing.DataBindings.Add("Text", DataSource, "OrgPriceClosing", "{0:n0}");

            //Get Parameter
            var param1 = new Parameter { Name = "CommuneReportPreparer" };
            Parameters.Add(param1);
            param1.Visible = false;
            txtCommuneReportPreparer.DataBindings.Add(new XRBinding(param1, "Text", ""));

            var param2 = new Parameter { Name = "CompanyAccountant" };
            Parameters.Add(param2);
            param2.Visible = false;
            txtCommuneChiefAccountant.DataBindings.Add(new XRBinding(param2, "Text", ""));

            var param3 = new Parameter { Name = "CompanyDirector" };
            Parameters.Add(param3);
            param3.Visible = false;
            txtCommuneDirector.DataBindings.Add(new XRBinding(param3, "Text", ""));

            //Get Sum 
            txtTotalQuantityOpening.DataBindings.Add("Text", null, "QuantityOpening");
            txtTotalQuantityOpening.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalQuantityInwardStock.DataBindings.Add("Text", null, "QuantityInwardStock");
            txtTotalQuantityInwardStock.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalQuantityOutwardStock.DataBindings.Add("Text", null, "QuantityOutwardStock");
            txtTotalQuantityOutwardStock.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalQuantityClosing.DataBindings.Add("Text", null, "QuantityClosing");
            txtTotalQuantityClosing.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalOrgPriceOpening.DataBindings.Add("Text", null, "OrgPriceOpening");
            txtTotalOrgPriceOpening.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalOrgPriceInwardStock.DataBindings.Add("Text", null, "OrgPriceInwardStock");
            txtTotalOrgPriceInwardStock.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalOrgPriceOutwardStock.DataBindings.Add("Text", null, "OrgPriceOutwardStock");
            txtTotalOrgPriceOutwardStock.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");

            txtTotalOrgPriceClosing.DataBindings.Add("Text", null, "OrgPriceClosing");
            txtTotalOrgPriceClosing.Summary = new XRSummary(SummaryRunning.Report, SummaryFunc.Sum, "{0:n0}");
        }

        private void txtQuantityOpening_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtQuantityOpening.Text.Trim()) == 0) { txtQuantityOpening.Text = ""; }
        }

        private void txtOrgPriceOpening_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtOrgPriceOpening.Text.Trim()) == 0) { txtOrgPriceOpening.Text = ""; }
        }

        private void txtQuantityInwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtQuantityInwardStock.Text.Trim()) == 0) { txtQuantityInwardStock.Text = ""; }
        }

        private void txtOrgPriceInwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtOrgPriceInwardStock.Text.Trim()) == 0) { txtOrgPriceInwardStock.Text = ""; }
        }

        private void txtQuantityOutwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtQuantityOutwardStock.Text.Trim()) == 0) { txtQuantityOutwardStock.Text = ""; }
        }

        private void txtOrgPriceOutwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtOrgPriceOutwardStock.Text.Trim()) == 0) { txtOrgPriceOutwardStock.Text = ""; }
        }

        private void txtQuantityClosing_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtQuantityClosing.Text.Trim()) == 0) { txtQuantityClosing.Text = ""; }
        }

        private void txtOrgPriceClosing_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtOrgPriceClosing.Text.Trim()) == 0) { txtOrgPriceClosing.Text = ""; }
        }




        private void txtTotalQuantityOpening_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtTotalQuantityOpening.Text.Trim()) == 0) { txtTotalQuantityOpening.Text = ""; }
        }

        private void txtTotalOrgPriceOpening_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtTotalOrgPriceOpening.Text.Trim()) == 0) { txtTotalOrgPriceOpening.Text = ""; }
        }

        private void txtTotalQuantityInwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtTotalQuantityInwardStock.Text.Trim()) == 0) { txtTotalQuantityInwardStock.Text = ""; }
        }

        private void txtTotalOrgPriceInwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtTotalOrgPriceInwardStock.Text.Trim()) == 0) { txtTotalOrgPriceInwardStock.Text = ""; }
        }

        private void txtTotalQuantityOutwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtTotalQuantityOutwardStock.Text.Trim()) == 0) { txtTotalQuantityOutwardStock.Text = ""; }
        }

        private void txtTotalOrgPriceOutwardStock_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtTotalOrgPriceOutwardStock.Text.Trim()) == 0) { txtTotalOrgPriceOutwardStock.Text = ""; }
        }

        private void txtTotalQuantityClosing_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (int.Parse(txtTotalQuantityClosing.Text.Trim()) == 0) { txtTotalQuantityClosing.Text = ""; }
        }

        private void txtTotalOrgPriceClosing_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (decimal.Parse(txtTotalOrgPriceClosing.Text.Trim()) == 0) { txtTotalOrgPriceClosing.Text = ""; }
        }

    }
}
